-- Creating a Nested Transaction
CREATE TABLE TestTrans(Cola INT PRIMARY KEY,
               Colb CHAR(3) NOT NULL);
GO
CREATE PROCEDURE TransProc @PriKey INT, @CharCol CHAR(3) AS
BEGIN TRANSACTION InProcINSERT INTO TestTrans VALUES (@PriKey, @CharCol)
INSERT INTO TestTrans VALUES (@PriKey + 1, @CharCol)
COMMIT TRANSACTION InProc;
GO
BEGIN TRANSACTION OutOfProc; 
GO
EXEC TransProc 1, 'aaa';
GO
ROLLBACK TRANSACTION OutOfProc; 
GO
EXECUTE TransProc 3,'bbb';
GO
SELECT * FROM TestTrans;
GO